<?php 
include('Upload.php');
$Upload = new Upload();
// GESTION DU FORMULAIRE D'UPLOAD

// Pour limiter la taille d'un fichier (exprim�e en ko)
$Upload->MaxFilesize = 1024;

// Pour indiquer le nombre de champs souhait�s
$Upload->Fields = 1;

// Initialisation du formulaire
$Upload->InitForm();
?>


<script type="text/javascript"> 
// wait for the DOM to be loaded 
$(document).ready(function() { 

	
  $("#image_valide").validate({
    rules: {
      nom: {
    		required: true,
    		minlength: 2
    	},
    	prenom: {
    		required: true,
    		minlength: 2
    	},
    	conditions_accepte: {
    		required: true
    	},
    	cp: {
    		required: true,
    		minlength: 5 		
    	},
      'userfile[]': {
    		required: true  		
    	},
    	email: {
    		required: true,
    		email: true    		
    	}
    },
    messages: {
    	nom: {
    		required:"Veuillez entrer votre nom",
    		minlength: "Votre nom doit comporter au moins 2 lettres"		        
    	},
    	prenom: {
    		required:"Veuillez entrer votre prenom",
    		minlength: "Votre prenom doit comporter au moins 2 lettres"	
    	},
     	conditions_accepte: {
    		required:"Veuillez accepter les conditions d'utilisations"
    	},
    	cp: {
    		required:"Veuillez entrer votre code postal",
    		minlength: "Votre code postal doit comporter 5 chiffres "
    	},
    	'userfile[]': {
    		required:"Veuillez chosir une photo"
    	},
    		email: "Veuillez entrer un email valide"
    }
    });

  /* $('#image_valide').ajaxForm({ 
     // target identifies the element(s) to update with the server response 
     target: '#result',  
         
     // success identifies the function to invoke when the server response 
     // has been received; here we apply a fade-in effect to the new content 
     success: function() { 
         $('#result').fadeIn('slow'); 
     }
   }); */
   
   function showResponse(responseText, statusText, xhr, $form)  { 
            // for normal html responses, the first argument to the success callback 
            // is the XMLHttpRequest object's responseText property 
         
            // if the ajaxSubmit method was passed an Options Object with the dataType 
            // property set to 'xml' then the first argument to the success callback 
            // is the XMLHttpRequest object's responseXML property 
         
            // if the ajaxSubmit method was passed an Options Object with the dataType 
            // property set to 'json' then the first argument to the success callback 
            // is the json data object returned by  the server 
           $("#result").html('<div id="login_error">'+ responseText + '</div>'); 
    }
});
</script>

	<div id="respond">
		<form enctype="multipart/form-data" id="image_valide" name="form1" method="post" action="">
		  <div id="cadre">
				<p class="form-slider" ><label>Nom</label><input type="text" class="input_1" id="nom" name="nom" value="<?php if(isset($_GET['nom'])) echo $_GET['nom']; ?>"></p>
				<p class="form-slider" ><label>Prénom</label><input type="text" class="input_1" id="prenom" name="prenom" value="<?php if(isset($_GET['prenom'])) echo $_GET['prenom']; ?>"></p>
				<p class="form-slider" ><label>Email</label><input type="text" class="input_1" id="email" name="email" value="<?php if(isset($_GET['email'])) echo $_GET['email']; ?>"></p>
				<p class="form-slider" ><label>Code postal</label><input type="text" maxlength="5" class="input_1" id="cp" name="cp" value="<?php if(isset($_GET['cp'])) echo $_GET['cp']; ?>"></p>
				<!--<p class="form-slider" ><label>Photo</label><input type="file" class="input_1" id="photo" name="photo"></p>-->
				<p class="form-slider" ><label>Photo</label><?php  print $Upload->Field[1] ?></p>
				<div id="cac" ><input type="checkbox" name="conditions_accepte" value="oui"><label>Je certifie que je dispose des droits d'utilisation de cette photo et j'accepte que celle-ci soit diffusée sur le site tousformidables.fr.</label></div>
			 <?php
  // Affichage du champ MAX_FILE_SIZE
  print $Upload->Field[0];
  
 
  ?>
			<script type="text/javascript"
				 src="http://www.google.com/recaptcha/api/challenge?k=6LczgN0SAAAAAAZ49I0PP9i1jE7VdNixRCdWOwry">
			 </script>
			 <noscript>
				 <iframe src="http://www.google.com/recaptcha/api/noscript?k=6LczgN0SAAAAAAZ49I0PP9i1jE7VdNixRCdWOwry"
					 height="300" width="500" frameborder="0"></iframe><br>
				 <textarea name="recaptcha_challenge_field" rows="3" cols="40">
				 </textarea>
				 <input type="hidden" name="recaptcha_response_field"
					 value="manual_challenge">
			  </noscript>
			  <?php if(isset($_GET['error'])){?>
			  <p class="form-slider" ><label class="error">Saisie incorrecte</label></p>
			<?php }?>
			</div>			 
			<div class="submit"><input type="submit" name="submit" value="Envoyer"></div>
		</form>
		<div id="result_gallerie"></div>
	</div>
	
